package routers

import (
	"HTchoujiang/controllers"
	"github.com/astaxie/beego"
	"github.com/astaxie/beego/context"
)

func init() {
	var FilterUser = func(c *context.Context) {
		if c.Request.RequestURI == "/login" {
			return
		}
		_, ok := c.Input.Session("uid").(int)
		if !ok {
			c.Redirect(302, "/login")
		}
	}
	beego.InsertFilter("*", beego.BeforeRouter, FilterUser)
	beego.Router("/", &controllers.MainController{})
	beego.Router("/index_v1.html", &controllers.MainController{}, "*:Index_v1")
	beego.Router("/login", &controllers.MainController{}, "*:Login")
	beego.Router("/logout", &controllers.MainController{}, "*:Logout")


	//Advertisement
	beego.Router("/advertisement/list_html/*", &controllers.AdvertisementController{}, "*:HTAdvertisementList_html")
	beego.Router("/advertisement/list", &controllers.AdvertisementController{}, "*:HTAdvertisementList")
	beego.Router("/advertisement/detail", &controllers.AdvertisementController{}, "*:HTAdvertisementDetail")
	beego.Router("/advertisement/add", &controllers.AdvertisementController{}, "*:HTAdvertisementAdd")
	beego.Router("/advertisement/update", &controllers.AdvertisementController{}, "*:HTAdvertisementUpdate")
	beego.Router("/advertisement/delete", &controllers.AdvertisementController{}, "*:HTAdvertisementDelete")
	beego.Router("/advertisement/picUp", &controllers.AdvertisementController{}, "*:HTAdvertisementPicUp")
	
	//Devices
	beego.Router("/devices/list_html/*", &controllers.DevicesController{}, "*:HTDevicesList_html")
	beego.Router("/devices/list", &controllers.DevicesController{}, "*:HTDevicesList")
	beego.Router("/devices/detail", &controllers.DevicesController{}, "*:HTDevicesDetail")
	beego.Router("/devices/add", &controllers.DevicesController{}, "*:HTDevicesAdd")
	beego.Router("/devices/update", &controllers.DevicesController{}, "*:HTDevicesUpdate")
	beego.Router("/devices/delete", &controllers.DevicesController{}, "*:HTDevicesDelete")
	beego.Router("/devices/changestatus", &controllers.DevicesController{}, "*:HTDevicesStatusChange")
	beego.Router("/devices/picUp", &controllers.DevicesController{}, "*:HTDevicesPicUp")
	
	//PointModule
	beego.Router("/pointmodule/list_html/*", &controllers.PointModuleController{}, "*:HTPointModuleList_html")
	beego.Router("/pointmodule/list", &controllers.PointModuleController{}, "*:HTPointModuleList")
	beego.Router("/pointmodule/detail", &controllers.PointModuleController{}, "*:HTPointModuleDetail")
	beego.Router("/pointmodule/add", &controllers.PointModuleController{}, "*:HTPointModuleAdd")
	beego.Router("/pointmodule/update", &controllers.PointModuleController{}, "*:HTPointModuleUpdate")
	beego.Router("/pointmodule/delete", &controllers.PointModuleController{}, "*:HTPointModuleDelete")
	beego.Router("/pointmodule/picUp", &controllers.PointModuleController{}, "*:HTPointModulePicUp")
	
	//DevicesCoupon
	beego.Router("/devicescoupon/list_html/*", &controllers.DevicesCouponController{}, "*:HTDevicesCouponList_html")
	beego.Router("/devicescoupon/list", &controllers.DevicesCouponController{}, "*:HTDevicesCouponList")
	beego.Router("/devicescoupon/detail", &controllers.DevicesCouponController{}, "*:HTDevicesCouponDetail")
	beego.Router("/devicescoupon/add", &controllers.DevicesCouponController{}, "*:HTDevicesCouponAdd")
	beego.Router("/devicescoupon/update", &controllers.DevicesCouponController{}, "*:HTDevicesCouponUpdate")
	beego.Router("/devicescoupon/delete", &controllers.DevicesCouponController{}, "*:HTDevicesCouponDelete")
	beego.Router("/devicescoupon/changestatus", &controllers.DevicesCouponController{}, "*:HTDevicesCouponStatusChange")
	
	//PointCommit
	beego.Router("/pointcommit/list_html/*", &controllers.PointCommitController{}, "*:HTPointCommitList_html")
	beego.Router("/pointcommit/list", &controllers.PointCommitController{}, "*:HTPointCommitList")
	beego.Router("/pointcommit/detail", &controllers.PointCommitController{}, "*:HTPointCommitDetail")
	beego.Router("/pointcommit/add", &controllers.PointCommitController{}, "*:HTPointCommitAdd")
	beego.Router("/pointcommit/update", &controllers.PointCommitController{}, "*:HTPointCommitUpdate")
	beego.Router("/pointcommit/delete", &controllers.PointCommitController{}, "*:HTPointCommitDelete")
	
	//Position
	beego.Router("/position/list_html/*", &controllers.PositionController{}, "*:HTPositionList_html")
	beego.Router("/position/list", &controllers.PositionController{}, "*:HTPositionList")
	beego.Router("/position/detail", &controllers.PositionController{}, "*:HTPositionDetail")
	beego.Router("/position/add", &controllers.PositionController{}, "*:HTPositionAdd")
	beego.Router("/position/update", &controllers.PositionController{}, "*:HTPositionUpdate")
	beego.Router("/position/delete", &controllers.PositionController{}, "*:HTPositionDelete")
	
	//UserCoupon
	beego.Router("/usercoupon/list_html/*", &controllers.UserCouponController{}, "*:HTUserCouponList_html")
	beego.Router("/usercoupon/list", &controllers.UserCouponController{}, "*:HTUserCouponList")
	beego.Router("/usercoupon/detail", &controllers.UserCouponController{}, "*:HTUserCouponDetail")
	beego.Router("/usercoupon/add", &controllers.UserCouponController{}, "*:HTUserCouponAdd")
	beego.Router("/usercoupon/update", &controllers.UserCouponController{}, "*:HTUserCouponUpdate")
	beego.Router("/usercoupon/delete", &controllers.UserCouponController{}, "*:HTUserCouponDelete")
	
	//UserDevicePoint
	beego.Router("/userdevicepoint/list_html/*", &controllers.UserDevicePointController{}, "*:HTUserDevicePointList_html")
	beego.Router("/userdevicepoint/list", &controllers.UserDevicePointController{}, "*:HTUserDevicePointList")
	beego.Router("/userdevicepoint/detail", &controllers.UserDevicePointController{}, "*:HTUserDevicePointDetail")
	beego.Router("/userdevicepoint/add", &controllers.UserDevicePointController{}, "*:HTUserDevicePointAdd")
	beego.Router("/userdevicepoint/update", &controllers.UserDevicePointController{}, "*:HTUserDevicePointUpdate")
	beego.Router("/userdevicepoint/delete", &controllers.UserDevicePointController{}, "*:HTUserDevicePointDelete")
	
	//Users
	beego.Router("/users/list_html/*", &controllers.UsersController{}, "*:HTUsersList_html")
	beego.Router("/users/list", &controllers.UsersController{}, "*:HTUsersList")
	beego.Router("/users/detail", &controllers.UsersController{}, "*:HTUsersDetail")
	beego.Router("/users/add", &controllers.UsersController{}, "*:HTUsersAdd")
	beego.Router("/users/update", &controllers.UsersController{}, "*:HTUsersUpdate")
	beego.Router("/users/delete", &controllers.UsersController{}, "*:HTUsersDelete")
	
	//WxMessage
	beego.Router("/wxmessage/list_html/*", &controllers.WxMessageController{}, "*:HTWxMessageList_html")
	beego.Router("/wxmessage/list", &controllers.WxMessageController{}, "*:HTWxMessageList")
	beego.Router("/wxmessage/detail", &controllers.WxMessageController{}, "*:HTWxMessageDetail")
	beego.Router("/wxmessage/add", &controllers.WxMessageController{}, "*:HTWxMessageAdd")
	beego.Router("/wxmessage/update", &controllers.WxMessageController{}, "*:HTWxMessageUpdate")
	beego.Router("/wxmessage/delete", &controllers.WxMessageController{}, "*:HTWxMessageDelete")
	
	//SQLLogs
	beego.Router("/sqllogs/list_html/*", &controllers.SQLLogsController{}, "*:HTSQLLogsList_html")
	beego.Router("/sqllogs/list", &controllers.SQLLogsController{}, "*:HTSQLLogsList")
	beego.Router("/sqllogs/detail", &controllers.SQLLogsController{}, "*:HTSQLLogsDetail")
	beego.Router("/sqllogs/add", &controllers.SQLLogsController{}, "*:HTSQLLogsAdd")
	beego.Router("/sqllogs/update", &controllers.SQLLogsController{}, "*:HTSQLLogsUpdate")
	beego.Router("/sqllogs/delete", &controllers.SQLLogsController{}, "*:HTSQLLogsDelete")
	

}
